<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?><?php echo Yii::app()->user->getPresentacionRol();?>" type="text/css">
		<link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" type="text/css">
		<meta name="viewport" content="width-device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0,minimum-scale=1.0">
 
	</head>
<style>
      html, body, #map-canvas {
        height: 100%;
        margin: 5px;
        padding: 0px
      }
    </style>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script> 
        <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyBfKE6Ncy85in6g8TBk7Umskb1EUzd1oMk&sensor=false"></script>
        <link rel="stylesheet" href="<?php echo Yii::app()->request->baseUrl; ?>css/jquery-ui-1.8.18.custom.css"/>
   <script type="text/javascript">
            var map;
            var geocoder;

            function initialize()
            {
                var myLatlong   =   new google.maps.LatLng(-34.774530, -58.267114);
                var myOptions   =   {
                                        zoom:16,
                                        center:myLatlong,
                                        mapTypeId:google.maps.MapTypeId.ROADMAP
                                    };
               map          =   new google.maps.Map(document.getElementById('map_canvas'),myOptions);
               geocoder      =   new google.maps.Geocoder();   
            }
            
          $(document).ready(function(){
              $("#autocomplete").autocomplete({
                  source:function(request,response){
                      geocoder.geocode({'address':request.term},function(results){
                          response($.map(results,function(item){
                              return {
                                 label:item.formatted_address,
                                 value:item.formatted_address,
                                 latitude:item.geometry.location.lat(),
                                 longitude:item.geometry.location.lng(),
								 
                              }
							 
                              
                          }))
						 
                      })
					 
                 },
                  select:function(event,ui) {
                    var location    =   new google.maps.LatLng(ui.item.latitude,ui.item.longitude);
                    marker          =   new google.maps.Marker({
                        map:map,
                        draggable:true
                    })
				  var stringvalue ="<input value="+ui.item.latitude+','+ui.item.longitude+" name='coordenadas'>";
                    $("#value").append(stringvalue);
                    marker.setPosition(location);
                    map.setCenter(location); 
					 
                }
                  
              })
			 
          
            });
        </script>

	<body>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'empleado-form',
	'enableAjaxValidation'=>true,
	'stateful'=>true,
	
)); ?>

		<div class="contenedor">
				<title>Registrar Profesional</title>
				
				<table id="iframe">
					<caption id="titulotabla">
						<h1>Registrar profesional</h1>
	  				</caption>
					<tr>
						<td>Nombre</td>
							<td>
							<div class="row">
								<?php echo $form->textField($model,'nombre'); ?>
								<?php echo $form->error($model,'nombre'); ?>
							</div>
							</td>
						<td>&nbsp;</td>
						<td rowspan="12">
							<div id="map_canvas" style="width:400px;height:350px"></div> 
						</td>
					</tr>
					<tr>
						<td>Apellido</td>
							<td>
							<div class="row">
								<?php echo $form->textField($model,'apellido'); ?>
								<?php echo $form->error($model,'apellido'); ?>
							</div>
							</td>
					</tr>
					<tr>
						<td>DNI</td>
							<td>
							<div class="row">
								<?php echo $form->textField($model,'dni'); ?>
								<?php echo $form->error($model,'dni'); ?>
							</div>
							</td>
					</tr>
					<tr>
						<td>Especialidad</td>
							<td>
							<div class="row">
								<?php echo $form->textField($model,'especialidad'); ?>
								<?php echo $form->error($model,'especialidad'); ?>
							</div>
							</td>
					</tr>
					<tr>
						<td>Tipo de transporte</td>
							<td>
							<div class="row">
								 <?php echo $form->dropDownList($model, 'transporte', array('driving' => 'Vehiculo','bicycling'=>'Bicicleta','walking' => 'Caminando')); ?>
								<?php echo $form->error($model,'transporte'); ?>
							</div>
							</td>
					</tr>
					<tr>
						<td>sucursal</td>
							<td>
							<div class="row">
								<?php echo $form->dropDownList($model, 'sucursal', array('1' => 'Florencio Varela', '2' => 'Berazategui','3'=>'Quilmes')); ?>
								<?php echo $form->error($model,'sucursal'); ?>
							</div>
							</td>
					</tr>
					<tr>
						<td>direccion</td>
							<td>
							<div class="row">
							<body onload="initialize()"></body>
							<?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
							        'model'=>$model,
									'attribute'=>'direccion',
									'sourceUrl'=> 'js:$("#autocomplete").val(data);',
									'htmlOptions'=>array(
										'size'=>20,
										'maxlength'=>45,
										'id'=>'autocomplete',
									
									),
									
								 ));?>
								 <?php echo $form->error($model,'direccion'); ?>
							</div>
							</td>
					
						<tr><td>&nbsp;</td></tr>
					<tr>
						<td>
							<div class="row buttons">
								<input name="button" type="button" onclick="parent.location='<?php echo $this->createUrl('profesionales'); ?>'" value="Cancelar" /> 
							</div>
						</td>
						<td colspan=2 align="right">
							<div class="row buttons">
								<?php echo CHtml::submitButton('Registrar profesional',array('name'=>'registrar')); ?>
							</div>
						</td>
					</tr>
				</table>
			</form>
<?php $this->endWidget(); ?>
		</div>
		</div>
	</body>
</html>